<template>
  <div>
    <div class="block">
      <ul>
        <li v-for="(item,index) in list" :key="index">
          {{ item }}
        </li>
      </ul>
      <span class="demonstration">共{{ list.length }}条记录  第 {{ singlePage }}/{{ toalPage }} 页</span>
      <el-button type="info" @click="beforePage">上一页</el-button>  <el-button type="info" :disabled="disabled" @click="nextPage">下一页</el-button>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      list: [1, 3, 4, 5, 2, 2, 2, 2, 2, 2, 2, 3, 3, 33, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],
      singlePage: 1,
      disabled: false,
      beforeDisable: false
    }
  },
  computed: {
    toalPage() {
      return this.list.length / 10
    }
  },
  methods: {
    nextPage() {
      if (this.singlePage < this.toalPage) {
        this.singlePage++
      } else if (this.singlePage === this.toalPage) {
        this.disabled = true
      }
    },
    beforePage() {
      if (this.singlePage > 1) {
        this.singlePage--
      }
      if (this.singlePage < this.toalPage) {
        this.disabled = false
      }
    }
  }
}
</script>
<style>
</style>
